#输入变量空值检查
chkVars=modulePath imageUrl
$(foreach var,${chkVars},$(eval $(call var_notnull,${var})))

#私有变量定义
myRoot=${projectRoot}
myHomer=${HOMER}
myModPath=${modulePath}
myImgUrl=${imageUrl}

#空值变量处理
myBaseImgUrl?=cfxl/alpine-jdk8

#宏定义 start
define mvn_run_direct
mvn $(1)
endef

define mvn_run_docker
docker run --rm -i -v ${myRoot}:/build -w /build --net host -e "https_proxy=${hp}" -v $${myHomer}/.m2:/root/.m2 --entrypoint=/bin/sh cfxl/alpine-jdk8-maven3:latest -c "cd ${myModPath} && mvn $(1)"
endef

define runMvn =
$(call mvn_run_$(T),$(1))
endef
# end宏定义

.PHONY: depx
depx:
	@echo current have no depends need todo

.PHONY: buildx
buildx: #在容器中构建
	$(call runMvn,install -DskipTests)

.PHONY: imagex
imagex: entryx#基于构建二进制，构建镜像
	$(call runMvn,compile jib:build -Djib.to.image=${myImgUrl} -Djib.from.image=${myBaseImgUrl})

.PHONY: testx
testx: #测试镜像
	docker run --rm -it  --net host ${myImgUrl}

.PHONY: cleanx
cleanx: #清空构建
	$(call runMvn,clean)